<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('商品列表')" />
	<th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								商品编号：<input type="text" name="goodsBh"/>
							</li>

							<li>
								商品名称：<input type="text" name="goodsName"/>
							</li>




							<li>商品类型： <select name="goodsLxId" class="selectpicker show-tick " data-live-search="true"
								data-none-selected-text="请选择">
									<option></option>
									<option id="goodsLxList" th:each="goodsLx:${goodsLxList}"
										th:value="${goodsLx.id}" th:text="${goodsLx.goodsLxName}"></option>
							</select>
							</li>



							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
								
				<a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="Goods:goods:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="Goods:goods:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('Goods:goods:edit')}]];
        var removeFlag = [[${@permission.hasPermi('Goods:goods:remove')}]];
        var prefix = ctx + "Goods/selledOutGoods";
      

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "商品",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'id', 
					title : 'id',
					visible: false
				},
				{
					field : 'goodsBh', 
					title : '商品编号',
					sortable: true
				},
				{
					field : 'goodsName', 
					title : '商品名称',
					sortable: true
				},
				
				{
				title: '图片',
			    formatter: function(value, row, index) {
			    	if($.common.isEmpty(row.goodsTp)){
			    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
			    	} else {
			    		return $.table.imageView(row.goodsTp);
			    	}
			    	// 图片预览（注意：如存储在本地直接获取数据库路径，如有配置context-path需要使用ctx+路径）
			    	// 如：/profile/upload/2019/08/08/3b7a839aced67397bac694d77611ce72.png
			    	/* if(index % 2 == 0){
			    		return $.table.imageView('/profile/avatar/2019/07/19/e9708796bb68b17dd1ffa1faea25ece7.jpg');
			    	}else {
			    		return $.table.imageView('http://demo.ruoyi.vip/ruoyi.png');
			    	} */
			    }
				},
				{
					field : 'goodsLxId', 
					title : '商品类型',
					sortable: true
				},
				
			
			
		
				{
					field : 'goodsStatus', 
					title : '商品状态',
					sortable: true
				},
			
			
			
			
				{
					field : 'goodsNowprice', 
					title : '现价',
					sortable: true
				},
				
				{
					field : 'goodsNum', 
					title : '库存',
					sortable: true
				},
				
				{
					field : 'goodsXl', 
					title : '销量',
					sortable: true
				},
				{
					field : 'goodsLayout', 
					title : '商品布局',
					sortable: true
				},
	
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="goodsUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> ');
                        actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="goodsUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>商品链接</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="goodsUpdate(\'' + row.id + '\')"><i class="fa fa-edit"></i>商品二维码</a> ');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        
        function goodsUpdate(id) {
        	$.modal.open('编辑商品', prefix + "/edit/" + id, '1300', '800');			
		}
        
        function goodsAdd() {
        	$.modal.open('添加商品', prefix + "/add/", '1300', '800');			
		}
    </script>
</body>
</html>